Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    moveDisappear: '',
    moveFlag: true, // 执行滑动效果
    startX: 0,
    endX: 0
  },
  /**
   * 组件的方法列表
   */
  methods: {
    /**
     * @description: 开始触摸
     * @param {type}
     * @return:
     */
    touchStart: function (event) {
      this.setData({
        startX: event.touches[0].pageX, // 获取触摸时的原点
        moveFlag: true
      })
    },
    /**
     * @description: 触摸移动事件
     * @param {type}
     * @return:
     */
    touchMove: function (event) {
      this.setData({
        endX: event.touches[0].pageX // 获取触摸时的原点
      })
      if (this.data.moveFlag) {
        if (this.data.endX - this.data.startX > 60) {
          console.log("move right:", this.data.endX - this.data.startX)
          this.move2right()
          this.setData({
            moveFlag: false
          })
        }

        if (this.data.startX - this.data.endX > 60) {
          console.log("move left:", this.data.startX - this.data.endX)
          // this.move2left()
          this.setData({
            moveFlag: false
          })
        }
      }
    },
    /**
     * @description: 触摸结束事件
     * @param {type}
     * @return:
     */
    touchEnd: function (event) {
      this.setData({
        moveFlag: true, // 回复滑动事件
        moveDisappear: ''
      })
    },
    /**
     * @description: 向左滑动操作
     * @param {type}
     * @return:
     */
    move2left() {
      let animation = wx.createAnimation({
        duration: 1000,
        timingFunction: 'ease',
        delay: 100
      });
      animation.opacity(0.2).translate(500, 0).step()
      this.setData({
        moveDisappear: animation.export()
      })
    },
    /**
     * @description: 向右滑动操作
     * @param {type}
     * @return:
     */
    move2right() {
      let animation = wx.createAnimation({
        duration: 1000,
        timingFunction: 'ease',
        delay: 100
      });
      animation.opacity(0.2).translate(500, 0).step()
      this.setData({
        moveDisappear: animation.export()
      })
    }
  }
})
